package com.unionbigdata.teaching.controller;

import com.unionbigdata.teaching.common.Result;
import com.unionbigdata.teaching.sevice.IUserService;
import com.unionbigdata.teaching.vo.UserVO;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/user")
@Tag(name = "用户信息")
public class UserController {

    @Autowired
    private IUserService testService;

    @Operation(summary = "根据Id查询用户信息")
    @GetMapping("/{id}")
    public Result<UserVO> findById(@PathVariable Long id) {
        return Result.ok(testService.findById(id));
    }

    @Operation(summary = "新增用户")
    @PostMapping
    public Result<Long> saveUser(@RequestBody UserVO userVO) {
        return Result.ok(testService.saveUser(userVO));
    }

    @Operation(summary = "查询用户列表")
    @GetMapping("/list")
    public Result<List<UserVO>> findUserList() {
        return Result.ok(testService.findUserList());
    }
}
